/**
 * 定义天数据模块
 */
(function(window, angular, undefined){
	var module = angular.module('water.apps.WasteGas.ReportData.avgStatistics.quarterDataManager', ['water.apps.WasteGas.reportHistory.reportMinDataManager',
	                                                                                  'water.common.dateUtil','water.entity.monitorData']);
	
	module.controller('reportAvgStatisticsQuarterController',function($rootScope,$scope,$controller,$dateUtil,$monitorDataService){

		var control = $controller("reportAvgStatisticsMinuteController",{$scope:$scope});
		
		$scope.dataAPIName = "monthListGetter";
		$scope.dataExportAPIName = "exportDayExcel";
		/**
		 * 开始时间
		 */
		$scope.startDate;
		/**
		 * 结束时间
		 */
		$scope.endDate;
		/**
		 * 获取查询参数,重写，跟基类不一样的地方在于，这里起始和结束时间直接取的是控件的值
		 * 而基类是通过选择小时，然后拼接
		 */
		// 周查询条件，年份
		$scope.yearlist=[];
		var currentYear=(new Date()).getFullYear();
		for(var i=0;i<4;i++){
			$scope.yearlist.push({
				name:currentYear-i+"年",
				value:currentYear-i+""
			});
		}; 
		$scope.quarterslist=[
			                 {name:"第1季度",value:"1"},
			                 {name:"第2季度",value:"2"},
			                 {name:"第3季度",value:"3"},
			                 {name:"第4季度",value:"4"}
			                ];
		/**
		 * 初始化
		 */
		function _init(){
			$scope.selectYear = $scope.yearlist[0].value;
			$scope.selectQuarter = $scope.quarterslist[0].value;
			var startMonth = 1 + (parseInt($scope.selectQuarter) - 1) * 3;
			$scope.startDate =$scope.selectYear + "-" + startMonth + "-01" + " 00:00:00";
			var date=new Date($scope.selectYear,(startMonth+2),0);
			$scope.endDate =$scope.selectYear + "-" + (startMonth+2) + "-"+date.getDate() + " 23:59:59";	
		}
		_init();
		$scope.getQueryObject = function(){
			var parmsStr = $scope.selectedModel.parmToChecksStr;
			var startMonth = 1 + (parseInt($scope.selectQuarter) - 1) * 3;
			$scope.startDate =$scope.selectYear + "-" + startMonth + "-01" + " 00:00:00";
			var date=new Date($scope.selectYear,(startMonth+2),0);
			$scope.endDate =$scope.selectYear + "-" + (startMonth+2) + "-"+date.getDate() + " 23:59:59";	
			var queryObject = {
					"MN":$scope.selectedModel.MN,
					"PARMS":parmsStr,
					"START":$scope.startDate,
					"END":$scope.endDate
				};
			return queryObject;
		}
		
	});
}(window, angular));	